//
//  InboxCell.m
//  MOPAI
//
//  Created by Lixiaoyong on 13-4-10.
//  Copyright (c) 2013年 . All rights reserved.
//

#import "InboxCell.h"

#import <QuartzCore/QuartzCore.h>

#define kCellHeight 70.0

@interface InboxCell()
@property (nonatomic,retain) UIView *mainView;
@end

@implementation InboxCell
@synthesize content,date;
@synthesize mainView;

- (void)dealloc
{
    self.mainView = nil;
    self.content = nil;
    self.date = nil;
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.mainView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
        self.mainView.backgroundColor = [UIColor clearColor];
        self.mainView.layer.borderColor = [UIColor lightGrayColor].CGColor;
        //self.mainView.layer.borderColor = [UIColor blackColor].CGColor;
        self.mainView.layer.borderWidth = 1.0;
        self.mainView.layer.cornerRadius = 6.0;
        [self addSubview:self.mainView];
        
        self.content = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        self.content.textColor = [UIColor blackColor];
        self.content.font = [UIFont fontWithName:@"Helvetia-Bold" size:13.5];
        self.content.backgroundColor = [UIColor clearColor];
        [self.mainView addSubview:self.content];
        
        self.date = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        self.date.textColor = [UIColor blackColor];
        self.date.font = [UIFont systemFontOfSize:14.0];
        self.date.backgroundColor = [UIColor clearColor];
        [self.mainView addSubview:self.date];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)refreshFrame:(float)width
{
    float height = kCellHeight;
    CGRect rect = CGRectMake(10, 5, width-20, height-10);
    self.mainView.frame = rect;
    
    float itemHeght = rect.size.height/3;
    rect = CGRectMake(10, 0, rect.size.width-20, itemHeght*2);
    self.content.frame = rect;
    rect.origin.y = rect.size.height;
    rect.size.height = itemHeght;
    self.date.frame = rect;
}
@end